Process communication method and apparatus, storage medium, and mobile terminal

ABSTRACT

A process communication method and apparatus, a storage medium, and a mobile terminal. The method comprises: when a system process needs to communicate with an application process, determining whether an idle communication thread is present in a thread pool of the application process ( 101 ); if no idle communication thread is present in the thread pool of the application process, creating a first target communication thread ( 102 ); and communicating with the system process using the first target communication thread ( 103 ). By creating a target communication thread in a thread pool of an application process, abnormalities such as a frozen screen, restart and stuttering of a mobile terminal are avoided.

This application claims the priority of the Chinese patent applicationfiled on Nov. 18, 2020, with the application number of 202011292054.1with the invention titled “PROCESS COMMUNICATION METHOD AND APPARATUS,STORAGE MEDIUM, AND MOBILE TERMINAL”, the entirety of which isincorporated by reference in this application.

BACKGROUND OF DISCLOSURE Field of Disclosure

The present application relates to the field of communicationtechnologies, and in particular, to a process communication method,device, storage medium and mobile terminal.

Description of Related Art

In the ANDROID operating system (Android®), data transmission is oftenrequired between applications and services. Generally, inter-processcommunication can be used. For example, the Binder mechanism can be usedto transmit data to obtain each other's data.

Currently, when an application and a service perform inter-processescommunication through the Binder mechanism, if the system processrequests to communicate with the application process when all threads inthe application process are in working state, it will cause the mobileterminal to freeze, restart, and laggy and encounter other anomalies.

SUMMARY Technical Problem

The embodiment of the present application provides a processcommunication method operable to prevent the occurrence of abnormalsituations such as screen freezing, restarting, and lagging of themobile terminal.

Technical Solution

In a first aspect, an embodiment of the present application provides aprocess communication method, including:

-   -   determining whether an application process has idle        communication threads in a thread pool of the application        process when a system process needs to communicate with the        application process;    -   creating a first target communication thread if the application        process has no idle communication thread in the thread pool of        the application process; and    -   using the first target communication thread to communicate with        the system process.

Further, in the process communication method, after using the firsttarget communication thread to communicate with the system process, themethod further includes:

-   -   determining again whether the application process has idle        communication threads in the thread pool of the application        process when the system process needs to communicate with the        application process again;    -   determining whether the number of idle communication threads in        the thread pool of the application process is not less than a        first preset number if the application process has an idle        communication thread in the thread pool of the application        process;    -   destroying the first target communication thread after the        communication between the first target communication thread and        the system process is completed if the number of idle        communication threads in the thread pool of the application        process is not less than the first preset number; and    -   using any of the idle communication threads to communicate with        the system process that needs to communicate again.

Further, in the process communication method, after determining whetherthe number of idle communication threads in the thread pool of theapplication process is not less than a first preset number, the methodfurther includes:

-   -   determining whether the first target communication thread is in        an idle state if the number of idle communication threads in the        thread pool of the application process is less than a first        preset number; and    -   using the first target communication thread to communicate with        the system process that needs to communicate again if the first        target communication thread is in an idle state.

Further, in the process communication method, after determining whetherthe first target communication thread is in an idle state, the methodfurther includes:

-   -   determining whether the number of idle communication threads in        the thread pool of the application process is not less than a        second preset number if the first target communication thread is        not in an idle state, wherein the second preset number is less        than the first preset number; and    -   using any idle communication thread to communicate with the        system process that needs to communicate again if the number of        idle communication threads in the thread pool of the application        process is not less than the second preset number.

Further, in the process communication method, after determining whetherthe number of idle communication threads in the thread pool of theapplication process is not less than a second preset number, the methodfurther includes:

-   -   creating a second target communication thread if the number of        idle communication threads in the thread pool of the application        process is less than the second preset number; and    -   using the second target communication thread to communicate with        the system process that needs to communicate again.

Further, in the process communication method, after determining whetherthe first target communication thread is in an idle state, the methodfurther includes:

-   -   creating a second target communication thread if the first        target communication thread is not in an idle state; and    -   using the second target communication thread to communicate with        the system process that needs to communicate again.

Further, in the process communication method, after determining whetherthe application process has idle communication threads in the threadpool of the application process, the method further includes:

-   -   using the idle communication threads to communicate with the        system process if the application process has idle communication        threads in the thread pool of the application process.

In a second aspect, an embodiment of the present application furtherprovides a process communication device, which is characterized bycomprising:

-   -   a determining module configured to determine whether the        application process has idle communication threads in a thread        pool of the application process when the system process needs to        communicate with the application process;    -   a creating module configured to create a first target        communication thread if the application process has no idle        communication thread in the thread pool of the application        process; and    -   a communication module configured to using the first target        communication thread to communicate with the system process.

In a third aspect, an embodiment of the present application furtherprovides a computer-readable storage medium, where a computer program isstored in the storage medium, and when the computer program runs on thecomputer, the computer is caused to execute the following method:

-   -   determining whether an application process has idle        communication threads in a thread pool of the application        process when a system process needs to communicate with the        application process;    -   creating a first target communication thread if the application        process has no idle communication thread in the thread pool of        the application process; and    -   using the first target communication thread to communicate with        the system process.

Further, in the computer-readable storage medium, after using the firsttarget communication thread to communicate with the system process, themethod further includes:

-   -   determining again whether the application process has idle        communication threads in the thread pool of the application        process when the system process needs to communicate with the        application process again;    -   determining whether the number of idle communication threads in        the thread pool of the application process is not less than a        first preset number if the application process has an idle        communication thread in the thread pool of the application        process;    -   destroying the first target communication thread after the        communication between the first target communication thread and        the system process is completed if the number of idle        communication threads in the thread pool of the application        process is not less than the first preset number; and    -   using any of the idle communication threads to communicate with        the system process that needs to communicate again.

Further, in the computer-readable storage medium, after determiningwhether the number of idle communication threads in the thread pool ofthe application process is not less than a first preset number, themethod further includes:

-   -   determining whether the first target communication thread is in        an idle state if the number of idle communication threads in the        thread pool of the application process is less than a first        preset number; and    -   using the first target communication thread to communicate with        the system process that needs to communicate again if the first        target communication thread is in an idle state.

Further, in the computer-readable storage medium, after determiningwhether the first target communication thread is in an idle state, themethod further includes:

-   -   determining whether the number of idle communication threads in        the thread pool of the application process is not less than a        second preset number if the first target communication thread is        not in an idle state, wherein the second preset number is less        than the first preset number; and    -   using any idle communication thread to communicate with the        system process that needs to communicate again if the number of        idle communication threads in the thread pool of the application        process is not less than the second preset number.

Further, in the computer-readable storage medium, after determiningwhether the number of idle communication threads in the thread pool ofthe application process is not less than a second preset number, themethod further includes:

-   -   creating a second target communication thread if the number of        idle communication threads in the thread pool of the application        process is less than the second preset number; and    -   using the second target communication thread to communicate with        the system process that needs to communicate again.

Further, in the computer-readable storage medium, after determiningwhether the first target communication thread is in an idle state, themethod further includes:

-   -   creating a second target communication thread if the first        target communication thread is not in an idle state; and    -   using the second target communication thread to communicate with        the system process that needs to communicate again.

Further, in the computer-readable storage medium, after determiningwhether the application process has idle communication threads in athread pool of the application process, the method further includes:

-   -   using the idle communication threads to communicate with the        system process if the application process has idle communication        threads in the thread pool of the application process.

In a fourth aspect, the embodiments of the present application alsoprovide a mobile terminal, the mobile terminal includes a processor anda memory, and a computer program is stored in the memory, and theprocessor calls the computer program stored in the memory to execute amethod comprising:

-   -   determining whether an application process has idle        communication threads in a thread pool of the application        process when a system process needs to communicate with the        application process;    -   using the idle communication threads to communicate with the        system process if the application process has idle communication        threads in the thread pool of the application process;    -   creating a first target communication thread if the application        process has no idle communication thread in the thread pool of        the application process;    -   using the first target communication thread to communicate with        the system process;    -   determining again whether the application process has idle        communication threads in the thread pool of the application        process when the system process needs to communicate with the        application process again;    -   determining whether the number of idle communication threads in        the thread pool of the application process is not less than a        first preset number if the application process has an idle        communication thread in the thread pool of the application        process;    -   destroying the first target communication thread after the        communication between the first target communication thread and        the system process is completed if the number of idle        communication threads in the thread pool of the application        process is not less than the first preset number; and    -   using any of the idle communication threads to communicate with        the system process that needs to communicate again.

Further, in the mobile terminal, after determining whether the number ofidle communication threads in the thread pool of the application processis not less than a first preset number, the method further includes:

-   -   determining whether the first target communication thread is in        an idle state if the number of idle communication threads in the        thread pool of the application process is less than a first        preset number; and    -   using the first target communication thread to communicate with        the system process that needs to communicate again if the first        target communication thread is in an idle state.

Further, in the mobile terminal, after determining whether the firsttarget communication thread is in an idle state, the method furtherincludes:

-   -   determining whether the number of idle communication threads in        the thread pool of the application process is not less than a        second preset number if the first target communication thread is        not in an idle state, wherein the second preset number is less        than the first preset number; and    -   using any idle communication thread to communicate with the        system process that needs to communicate again if the number of        idle communication threads in the thread pool of the application        process is not less than the second preset number.

Further, in the mobile terminal, after determining whether the number ofidle communication threads in the thread pool of the application processis not less than a second preset number, the method further includes:

-   -   creating a second target communication thread if the number of        idle communication threads in the thread pool of the application        process is less than the second preset number; and    -   using the second target communication thread to communicate with        the system process that needs to communicate again.

Further, in the mobile terminal, after determining whether the firsttarget communication thread is in an idle state, the method furtherincludes:

-   -   creating a second target communication thread if the first        target communication thread is not in an idle state; and    -   using the second target communication thread to communicate with        the system process that needs to communicate again.

Beneficial effects: The present invention provides a processcommunication method, comprising: when a system process needs tocommunicate with an application process, determining whether theapplication process has idle communication threads in a thread pool ofthe application process; if the application process has no idlecommunication thread in the thread pool of the application processthread, creating a first target communication thread; using the firsttarget communication thread to communicate with the system process. Bycreating a target communication thread when the application process hasno idle communication thread in the thread pool of the applicationprocess. Thus, the situation that the system process cannot communicatewith the application process is avoided, thereby avoiding the occurrenceof abnormal situations such as screen freezing, restarting, and laggingof the mobile terminal.

Beneficial Effects of the Invention

BRIEF DESCRIPTION OF DRAWINGS

In order to illustrate the technical solutions in the embodiments of thepresent application more clearly, the following briefly introduces thedrawings that are used in the description of the embodiments. Obviously,the drawings in the following description are only some embodiments ofthe present application. For those skilled in the art, other drawingscan also be obtained from these drawings without creative effort.

FIG. 1 a is a first schematic flowchart of a process communicationmethod provided by an embodiment of the present application.

FIG. 1B is a schematic diagram showing the principle of inter-processcommunication provided by an embodiment of the present application.

FIG. 2 is a second schematic flowchart of process communication methodprovided by an embodiment of the present application.

FIG. 3 is a schematic structural diagram of a process communicationapparatus provided by an embodiment of the present application.

FIG. 4 is a specific structural diagram of a mobile terminal provided byan embodiment of the present application.

DETAILED DESCRIPTION OF EMBODIMENTS

The technical solutions in the embodiments of the present applicationwill be clearly and completely described below with reference to theaccompanying drawings in the embodiments of the present application.Obviously, the described embodiments are only a part of the embodimentsof the present application, but not all of the embodiments. Based on theembodiments in the present application, all other embodiments obtainedby those skilled in the art without creative work fall within theprotection scope of the present application.

Please refer to FIG. 1 a . FIG. 1 a is a first schematic flowchart of aprocess communication method provided by an embodiment of the presentapplication. The process communication method includes:

Step 101: determining, when a system process needs to communicate withan application process, whether the application process has idlecommunication threads in a thread pool of the application process.

In particular, the system process needs to communicate with theapplication process through the Binder mechanism. Binder is a way ofinter-process communication (IPC) in the Android system, and it is alsoone of the most important features in the Android system and services asa bridge for inter-process communication between four major componentworkflows (Activities) in Android are service (Service), broadcastreceiver (Broadcast), content provider (ContentProvider), and differentapplications (App), all of which run in different processes. Just likeits name “Binder”, it glues the various components of the systemtogether and acts as a bridge for each component.

Specifically, please refer to FIG. 1B, which is a schematic diagramshowing the principle of inter-process communication provided by anembodiment of the present application. In particular, each Androidprocess can only run in the virtual address space owned by its ownprocess. For example, it corresponds to a 4 GB virtual address space, ofwhich 3 GB is the user space and 1 GB is the kernel space. Of course,the size of the kernel space can be adjusted by parameter configuration.For user space, different processes cannot share with each other, butkernel space can be shared. The communication between the applicationprocess and the system process is actually achieved by using the kernelmemory space that can be shared between processes for the underlyingcommunication work. The application process and the system process oftenuse ioctl (a function for a device driver to manage the I/O channel ofthe device) and other methods to interact with the drivers in the kernelspace.

In particular, it can be determined whether there is an idlecommunication thread in the thread pool by determining whether eachthread in the thread pool of the application process that the systemprocess needs to communicate with is in an idle state.

Specifically, whether a process is a system process can be determined bydetermining the upper limit of the number of threads corresponding tothe process. Since the upper limit of the number of threads in thesystem process can be 32, and the upper limit of the number of threadsin other processes is 16, if the upper limit of the number of threads inthe process is 32, it can be determined that the process is a systemprocess.

Step 102: creating a first target communication thread if theapplication process has no idle communication thread in the thread poolof the application process.

In particular, if all the communication threads in the thread pool ofthe application process are in a working state or a communication state,it can be determined that there are no idle communication threads in thethread pool. Since the system process needs to communicate with theapplication process, a target communication thread can be created, so asto realize the communication between the system process and theapplication process.

Step 103: using the first target communication thread to communicatewith the system process.

After the first target communication thread is created in step 102, thefirst target communication thread can be used to communicate with thesystem process.

In some embodiments, after using the first target communication threadto communicate with the system process, the method further includes:

-   -   (1) determining again whether the application process has idle        communication threads in the thread pool of the application        process when the system process needs to communicate with the        application process again;    -   (2) determining whether the number of idle communication threads        in the thread pool of the application process is not less than a        first preset number if the application process has an idle        communication thread in the thread pool of the application        process;    -   (3) destroying the first target communication thread after the        communication between the first target communication thread and        the system process is completed if the number of idle        communication threads in the thread pool of the application        process is not less than the first preset number;    -   (4) using any of the idle communication threads to communicate        with the system process that needs to communicate again.

In particular, if the system process requests to communicate with theapplication process again, since it is unknown whether the applicationprocess has idle communication threads in the thread pool of theapplication process at the current time point, it is necessary tore-determine whether there are idle communication threads. In addition,in order to avoid that the tasks of the application process itselfcannot be processed by the threads due to the insufficient number ofidle communication threads, it is also necessary to determine whetherthe number of idle communication threads is not less than the firstpreset number, for example, 5. If it is not less than the first presetnumber, the first target communication thread may be destroyed after thecommunication between the system process and the application process onthe first target communication thread is completed. Any idlecommunication thread can be used to communicate with the system processthat needs to communicate again.

In some embodiments, after determining whether the number of idlecommunication threads in the thread pool of the application process isnot less than a first preset number, the method further includes:

-   -   (1) determining whether the first target communication thread is        in an idle state if the number of idle communication threads in        the thread pool of the application process is less than a first        preset number;    -   (2) using the first target communication thread to communicate        with the system process that needs to communicate again if the        first target communication thread is in an idle state.

In particular, if the number of idle communication threads in the threadpool is less than the first preset number, it is determined whether thefirst target communication thread is in an idle state at the currenttime point. If it is in an idle state, the first target communicationthread is preferentially used for communication.

In some embodiments, after determining whether the first targetcommunication thread is in an idle state, the method further includes:

-   -   (1.1) creating a second target communication thread if the first        target communication thread is not in an idle state;    -   (1.2) using the second target communication thread to        communicate with the system process that needs to communicate        again.

In particular, if the first target communication thread is not in anidle state, a second target communication thread needs to be createdagain, and using the second target communication thread to communicatewith the system process that needs to communicate again.

In some embodiments, after determining whether the first targetcommunication thread is in an idle state, the method further includes:

-   -   (1.1) determining whether the number of idle communication        threads in the thread pool of the application process is not        less than a second preset number if the first target        communication thread is not in an idle state, and the second        preset number is less than the first preset number;    -   (1.2) using any idle communication thread to communicate with        the system process that needs to communicate again if the number        of idle communication threads in the thread pool of the        application process is not less than the second preset number.

In particular, if it is detected that the first target communicationthread at the current time point is not in an idle state, then it isfurther detected whether the number of idle communication threads in thethread pool is not less than a second preset number, where the secondpreset number is typically 2 or 3. The purpose of setting the secondpreset number is to prevent the communication of the system process fromaffecting the task processing of the application process itself, so thesecond preset number of threads will be reserved for the applicationprocess itself. Therefore, if the number of idle threads in the threadpool is not less than the second preset number, any idle communicationthread is used for communication.

In some embodiments, after determining whether the number of idlecommunication threads in the thread pool of the application process isnot less than a second preset number, the method further includes:

-   -   (1.1) creating a second target communication thread if the        number of idle communication threads in the thread pool of the        application process is less than the second preset number;    -   (1.2) using the second target communication thread to        communicate with the system process that needs to communicate        again.

In particular, if the number of idle communication threads in the threadpool is less than the second preset number, that is, if idlecommunication threads are used for system process and applicationprocesses, the application process's own task cannot be processed.Therefore, it is forbidden to use idle communication threads tocommunicate with system process. In order to ensure the normalcommunication of the system process, a second target communicationthread can be created subsequently, and the second target communicationthread can be used to communicate with the system process.

In some embodiments, after determining whether the application processhas idle communication threads in the thread pool of the applicationprocess, the method further includes:

-   -   (1) using the idle communication threads to communicate with the        system process if the application process has idle communication        threads in the thread pool of the application process.

In particular, if there is an idle communication thread in the threadpool, the idle communication thread is directly used to communicate withthe system process, and there is no need to create a first targetcommunication thread.

It can be seen from the above that in the embodiment of the presentapplication, when the system process needs to communicate with theapplication process, it is determined whether the application processhas idle communication threads in a thread pool of the applicationprocess. If the application process has no idle communication thread inthe thread pool of the application process, a first target communicationthread is created. The first target communication thread is used tocommunicate with the system process. By creating a target communicationthread when the application process has no idle communication thread inthe thread pool of the application process, the situation that thesystem process cannot communicate with the application process isavoided, thereby avoiding the occurrence of abnormal situations such asscreen freezing, restarting, and lagging of the mobile terminal.

In some embodiments, as shown in FIG. 2 , a process communication methodis provided, and the process communication method includes:

Step 201: determining whether an application process has idlecommunication threads in a thread pool of the application process when asystem process needs to communicate with the application process.

In particular, the system process needs to communicate with theapplication process through the Binder mechanism. Binder is a way ofinter-process communication (IPC) in the Android system, and it is alsoone of the most important features in the Android system and services asa bridge for inter-process communication between four major componentworkflows (Activities) in Android are service (Service), broadcastreceiver (Broadcast), content provider (ContentProvider), and differentapplications (App), all of which run in different processes. Just likeits name “Binder”, it glues the various components of the systemtogether and acts as a bridge for each component.

In particular, it can be determined whether there are idle communicationthreads in the thread pool by determining whether each thread in thethread pool of the application process that the system process needs tocommunicate with is in an idle state.

Specifically, whether it is a system process can be determined bydetermining the upper limit of the number of threads corresponding tothe process. Since the upper limit of the number of threads in thesystem process can be 32, and the upper limit of the number of threadsin other processes is 16, if the upper limit of the number of threads inthe process is 32, it can be determined that the process is a systemprocess.

Step 202: creating a first target communication thread if theapplication process has no idle communication thread in the thread poolof the application process.

In particular, if all the communication threads in the thread pool ofthe application process are in the working state or the communicationstate, it can be determined that there are no idle communication threadsin the thread pool. Since the system process needs to communicate withthe application process, a target communication thread can be created,so as to realize the communication between the system process and theapplication process.

Step 203: using the first target communication thread to communicatewith the system process.

After the first target communication thread is created in step 203, thefirst target communication thread can be used to communicate with thesystem process.

Step 204: determining again whether the application process has idlecommunication threads in the thread pool of the application process whenthe system process needs to communicate with the application processagain.

In particular, if the system process requests to communicate with theapplication process again, since it is unknown whether the applicationprocess has idle communication threads in the thread pool of theapplication process at the current time point, it is necessary tore-determine whether there are idle communication threads. In addition,in order to avoid that the task of the application process itself cannotbe processed by the threads due to the insufficient number of idlecommunication threads, it is also necessary to determine whether thenumber of idle communication threads is not less than the first presetnumber, for example, 5. If it is not less than the first preset number,the first target communication thread may be destroyed after thecommunication between the system process and the application process onthe first target communication thread is completed. Any idlecommunication thread can be used to communicate with the system processthat needs to communicate again.

Step 205: determining whether the number of idle communication threadsin the thread pool of the application process is not less than a firstpreset number if the application process has an idle communicationthread in the thread pool of the application process.

Step 206: determining whether the first target communication thread isin an idle state if the number of idle communication threads in thethread pool of the application process is less than a first presetnumber.

In particular, if the number of idle communication threads in the threadpool is less than the first preset number, it is determined whether thefirst target communication thread is in an idle state at the currenttime point. If it is in an idle state, the first target communicationthread is preferentially used for communication.

Step 207: If the first target communication thread is not in an idlestate, the thread pools of the application process, are took for thedetermination. Among the thread pools of the application process, if itis detected that the first target communication thread at the currenttime point is not in an idle state, then it is determined whether thenumber of communication threads is not less than the second presetnumber, where the second preset number is typically 2 or 3. The purposeof setting the second preset number is to prevent the communication ofthe system process from affecting the task processing of the applicationprocess itself. Therefore, the second preset number of threads will bereserved for the application process itself. Therefore, if the number ofthreads is not less than the second preset number, any idlecommunication thread is used for communication.

Step 208: creating a second target communication thread if the number ofidle communication threads in the thread pool of the application processis less than the second preset number.

In particular, if the number of idle communication threads in the threadpool is less than the second preset number, that is, if idlecommunication threads are used for system process and applicationprocesses, the application process's own task cannot be processed.Therefore, it is forbidden to use idle communication threads tocommunicate with system process. In order to ensure the normalcommunication of the system process, a second target communicationthread can be created subsequently, and the second target communicationthread can be used to communicate with the system process.

Step 209: using the second target communication thread to communicatewith the system process that needs to communicate again.

It can be seen from the above that in the embodiment of the presentapplication, when the system process needs to communicate with theapplication process, it is determined whether the application processhas idle communication threads in a thread pool of the applicationprocess. If the application process has no idle communication thread inthe thread pool of the application process, a first target communicationthread is created. The first target communication thread is used tocommunicate with the system process. By creating a target communicationthread when the application process has no idle communication thread inthe thread pool of the application process, the situation that thesystem process cannot communicate with the application process isavoided, thereby avoiding the occurrence of abnormal situations such asscreen freezing, restarting, and lagging of the mobile terminal.

In order to facilitate better implementation of the processcommunication method provided by the embodiment of the presentapplication, an embodiment also provides a process communicationapparatus. The meanings of the nouns are the same as those in the aboveprocess communication method, and the specific details forimplementation may refer to the descriptions in the method embodiments.

In some embodiments, a process communication apparatus is also provided.As shown in FIG. 3 , the process communication apparatus may include: adetermining module 301, a creating module 302, a communication module303, a second reporting module 304, and the like.

The determining module 301 is used to determine whether the applicationprocess has idle communication threads in a thread pool of theapplication process when the system process needs to communicate withthe application process;

A creating module 302, configured to create a first target communicationthread if the application process has no idle communication thread inthe thread pool of the application process;

The communication module 303 is configured to using the first targetcommunication thread to communicate with the system process.

During specific implementation, the above units can be implemented asindependent entities, or can be arbitrarily combined to be implementedas the same or several entities. The specific implementation of theabove units can refer to the previous method embodiments, which will notbe repeated here.

It can be seen from the above that the process communication method ofthe embodiment of the present application adopts the determining module301 to determine whether the application process has idle communicationthreads in a thread pool of the application process when the systemprocess needs to communicate with the application process. If there isno idle communication thread in the thread pool of the applicationprocess, a first target communication thread is created. Thecommunication module 303 uses the first target communication thread tocommunicate with the system process. By creating a target communicationthread when the application process has no idle communication thread inthe thread pool of the application process, the situation that thesystem process cannot communicate with the application process isavoided, thereby avoiding the occurrence of abnormal situations such asscreen freezing, restarting, and lagging of the mobile terminal.

Embodiments of the present application also provide a computer-readablestorage medium, where a computer program is stored in the storagemedium, and when the computer program runs on the computer, the computeris caused to execute the following method:

-   -   determining whether an application process has idle        communication threads in a thread pool of the application        process when a system process needs to communicate with the        application process;    -   creating a first target communication thread if the application        process has no idle communication thread in the thread pool of        the application process;    -   using the first target communication thread to communicate with        the system process.

In particular, after using the first target communication thread tocommunicate with the system process, the method further includes:

-   -   determining again whether the application process has idle        communication threads in the thread pool of the application        process when the system process needs to communicate with the        application process again;    -   determining whether the number of idle communication threads in        the thread pool of the application process is not less than a        first preset number if the application process has an idle        communication thread in the thread pool of the application        process;    -   destroying the first target communication thread after the        communication between the first target communication thread and        the system process is completed if the number of idle        communication threads in the thread pool of the application        process is not less than the first preset number;    -   using any of the idle communication threads to communicate with        the system process that needs to communicate again.

In particular, after determining whether the number of idlecommunication threads in the thread pool of the application process isnot less than the first preset number, the method further includes:

-   -   determining whether the first target communication thread is in        an idle state if the number of idle communication threads in the        thread pool of the application process is less than a first        preset number;    -   using the first target communication thread to communicate with        the system process that needs to communicate again if the first        target communication thread is in an idle state.

In particular, after determining whether the first target communicationthread is in an idle state, the method further includes:

-   -   determining whether the number of idle communication threads in        the thread pool of the application process is not less than a        second preset number if the first target communication thread is        not in an idle state, wherein the second preset number is less        than the first preset number;    -   using any idle communication thread to communicate with the        system process that needs to communicate again if the number of        idle communication threads in the thread pool of the application        process is not less than the second preset number.

In particular, after determining whether the number of idlecommunication threads in the thread pool of the application process isnot less than the second preset number, the method further includes:

-   -   creating a second target communication thread if the number of        idle communication threads in the thread pool of the application        process is less than the second preset number;    -   using the second target communication thread to communicate with        the system process that needs to communicate again.

In particular, after determining whether the first target communicationthread is in an idle state, the method further includes:

-   -   creating a second target communication thread if the first        target communication thread is not in an idle state;    -   using the second target communication thread to communicate with        the system process that needs to communicate again.

In particular, after determining whether the application process hasidle communication threads in the thread pool of the applicationprocess, the method further includes:

-   -   using the idle communication threads to communicate with the        system process if the application process has idle communication        threads in the thread pool of the application process.

Based on the above method, the present invention also provides a storagemedium on which a plurality of instructions are stored, wherein theinstructions are applicable for being loaded by a processor andexecuting the above-mentioned shooting method.

Those of ordinary skill in the art can understand that all or part ofthe steps in the various methods of the above embodiments can becompleted by instructing relevant hardware through a program, and theprogram can be stored in a computer-readable storage medium, and thestorage medium can include: Read only memory (ROM), random access memory(RAM), magnetic disk or optical disk, etc.

The embodiment of the present application also provides a mobileterminal, the mobile terminal includes a processor and a memory, acomputer program is stored in the memory, and the processor calls thecomputer program stored in the memory to execute a method comprising:

-   -   determining whether an application process has idle        communication threads in a thread pool of the application        process when a system process needs to communicate with the        application process;    -   using the idle communication threads to communicate with the        system process if the application process has idle communication        threads in the thread pool of the application process;    -   creating a first target communication thread if the application        process has no idle communication thread in the thread pool of        the application process;    -   using the first target communication thread to communicate with        the system process;    -   determining again whether the application process has idle        communication threads in the thread pool of the application        process when the system process needs to communicate with the        application process again;    -   determining whether the number of idle communication threads in        the thread pool of the application process is not less than a        first preset number if the application process has an idle        communication thread in the thread pool of the application        process;    -   destroying the first target communication thread after the        communication between the first target communication thread and        the system process is completed if the number of idle        communication threads in the thread pool of the application        process is not less than the first preset number;    -   using any of the idle communication threads to communicate with        the system process that needs to communicate again.

In particular, after determining whether the number of idlecommunication threads in the thread pool of the application process isnot less than the first preset number, the method further includes:

-   -   determining whether the first target communication thread is in        an idle state if the number of idle communication threads in the        thread pool of the application process is less than a first        preset number;    -   using the first target communication thread to communicate with        the system process that needs to communicate again if the first        target communication thread is in an idle state.

In particular, after determining whether the first target communicationthread is in an idle state, the method further includes:

-   -   determining whether the number of idle communication threads in        the thread pool of the application process is not less than a        second preset number if the first target communication thread is        not in an idle state, wherein the second preset number is less        than the first preset number;    -   using any idle communication thread to communicate with the        system process that needs to communicate again if the number of        idle communication threads in the thread pool of the application        process is not less than the second preset number.

In particular, after determining whether the number of idlecommunication threads in the thread pool of the application process isnot less than the second preset number, the method further includes:

-   -   creating a second target communication thread if the number of        idle communication threads in the thread pool of the application        process is less than the second preset number;    -   using the second target communication thread to communicate with        the system process that needs to communicate again.

In particular, after determining whether the first target communicationthread is in an idle state, the method further includes:

-   -   creating a second target communication thread if the first        target communication thread is not in an idle state;    -   using the second target communication thread to communicate with        the system process that needs to communicate again.

FIG. 4 shows a specific structural block diagram of a terminal providedby an embodiment of the present invention, and the terminal may be usedto implement the photographing method, storage medium, and terminalprovided in the foregoing embodiments.

As shown in FIG. 4 , the mobile terminal 1200 may include an radiofrequency (RF) circuit 110, a memory 120 including one or more (only oneis shown in the figure) computer-readable storage media, an input unit130, and a display unit 140, the sensor 150, the audio circuit 160, thetransmission module (Tx module) 170, the processor 180 including one ormore (only one is shown in the figure) processing core, and the powersupply (PS) 190 and other components. Those skilled in the art canunderstand that the structure of the mobile terminal 1200 shown in FIG.4 does not constitute a limitation to the mobile terminal 1200, and mayinclude more or less components than the one shown, or combine somecomponents, or different components layout. In particular:

RF circuitry 110 may include various existing circuit elements forperforming these functions, e.g., antennas, radio frequencytransceivers, digital signal processors, encryption/decryption chips,subscriber identity module (SIM) cards, memory, and the like. The RFcircuit 110 may communicate with various networks such as the Internet,an intranet, a wireless network, or with a second device over a wirelessnetwork. The aforementioned wireless network may include a cellulartelephone network, a wireless local area network, or a metropolitan areanetwork.

The memory 120 can be used to store software programs and modules, suchas the program instructions/modules corresponding to the processcommunication method, device, storage medium and mobile terminal in theabove-mentioned embodiments. The processor 180 runs the softwareprograms and modules stored in the memory 120, thereby execute variousfunctional applications and data processing, that is, realize thefunction of mutual recognition of chips. Memory 120 may includehigh-speed random access memory, and may also include non-volatilememory, such as one or more magnetic storage devices, flash memory, or asecond non-volatile solid-state memory. In some instances, memory 120may be a storage medium as described above.

The input unit 130 may be used to receive input numerical or characterinformation, and generate keyboard, mouse, joystick, optical ortrackball signal input related to user settings and function control.Specifically, the input unit 130 may include a touch-sensitive surface131 as well as other input devices 132. Touch-sensitive surface 131,also known as a touch display or trackpad, collects touch operations bya user on or near it (such as a user operates using a finger, stylus,etc., any suitable object or accessory on or near touch-sensitivesurface 131), and drive the corresponding connection device according toa preset program. Optionally, the touch-sensitive surface 131 mayinclude two parts, a touch detection device and a touch controller.

The display unit 140 may be used to display information input by orprovided to the user and various graphical user interfaces of the mobileterminal 1200, which may be composed of graphics, text, icons, videos,and any combination thereof. The display unit 140 may include a displaypanel 141, and further, the touch-sensitive surface 131 may cover thedisplay panel 141. The display interface of the mobile terminal in theabove-mentioned embodiment may be displayed by the display unit 140,that is, the display content of the display shot may be displayed by thedisplay unit 140.

The mobile terminal 1200 may further include at least one sensor 150,such as a light sensor, a motion sensor, and a second sensor.Specifically, the light sensor may include an ambient light sensor and aproximity sensor, wherein the ambient light sensor may adjust thebrightness of the display panel 141 according to the brightness of theambient light, and the proximity sensor may close the display panel 141when the mobile terminal 1200 is moved to the ear and/or backlight. Asfor the second sensor such as a gyroscope, a barometer, a hygrometer, athermometer, and an infrared sensor that can be configured in the mobileterminal 1200, details are not described here.

The audio circuit 160, the speaker 161, and the microphone 162 mayprovide an audio interface between the user and the mobile terminal1200. The audio circuit 160 can transmit the received audio dataconverted electrical signal to the speaker 161, and the speaker 161converts it into a sound signal for output. On the other hand, themicrophone 162 converts the collected sound signal into an electricalsignal, which is received and converted by the audio circuit 160 intoaudio data, and then the audio data is output to the processor 180 forprocessing, and then sent to, for example, another terminal through theRF circuit 110, or the audio data is output to the memory 120 forfurther processing. The audio circuit 160 may also include an earphonejack to provide communication between peripheral headphones and themobile terminal 1200.

The mobile terminal 1200 can help the user to send and receive emails,browse web pages, access streaming media, etc. through the transmissionmodule 170, and provide the user with wireless broadband Internetaccess.

The processor 180 is the control center of the mobile terminal 1200,uses various interfaces and lines to connect various parts of the entiremobile phone, runs or executes the software programs and/or modulesstored in the memory 120, and calls the data stored in the memory 120,perform various functions of the mobile terminal 1200 and process data,so as to monitor the mobile phone as a whole. Optionally, the processor180 may include one or more processing cores. In some embodiments, theprocessor 180 may integrate an application processor and a modemprocessor, wherein the application processor mainly handles theoperating system, user interface and applications, etc., the modemprocessor mainly deals with wireless communication. It can be understoodthat, the above-mentioned modulation and demodulation processor may notbe integrated into the processor 180.

Specifically, the processor 180 includes: an arithmetic logic operationunit (ALU), application processor, global positioning system (GPS) andcontrol and status bus (Bus) (not shown in the figure).

The mobile terminal 1200 also includes a power source 190 (such as abattery) for powering various components. In some embodiments, the powersource can be logically connected to the processor 180 through a powermanagement system, so as to manage power supply, discharge, and powerconsumption through the power management system. The power source 190may also include one or more DC or AC power sources, repower systems,power failure detection circuits, power converters or inverters, powerstatus indicators, and any other components.

Although not shown, the mobile terminal 1200 may further include acamera (e.g., a front-facing camera, a rear-facing camera), a Bluetoothmodule, and the like, which will not be repeated here.

Specifically in this embodiment, the display unit 140 of the mobileterminal 1200 is a touch screen display, and the mobile terminal 1200further includes a memory 120 and one or more programs, where one ormore of the programs are stored in memory 120 and are configured to beexecuted by one or more of the processors 180 one or more of theprograms contain instructions for performing:

-   -   determining whether an application process has idle        communication threads in a thread pool of the application        process when a system process needs to communicate with the        application process;    -   creating a first target communication thread if the application        process has no idle communication thread in the thread pool of        the application process;    -   using the first target communication thread to communicate with        the system process.

In some embodiments, after using the first target communication threadto communicate with the system process, the processor 380 may furtherexecute instructions for the following operations:

-   -   determining again whether the application process has idle        communication threads in the thread pool of the application        process when the system process needs to communicate with the        application process again;    -   determining whether the number of idle communication threads in        the thread pool of the application process is not less than a        first preset number if the application process has an idle        communication thread in the thread pool of the application        process;    -   destroying the first target communication thread after the        communication between the first target communication thread and        the system process is completed if the number of idle        communication threads in the thread pool of the application        process is not less than the first preset number;    -   using any of the idle communication threads to communicate with        the system process that needs to communicate again.

In some embodiments, after determining whether the number of idlecommunication threads in the thread pool of the application process isnot less than the first preset number, the processor 380 may furtherexecute an instruction of the following operations:

-   -   determining whether the first target communication thread is in        an idle state if the number of idle communication threads in the        thread pool of the application process is less than a first        preset number;    -   using the first target communication thread to communicate with        the system process that needs to communicate again if the first        target communication thread is in an idle state.

In some embodiments, after determining whether the first targetcommunication thread is in an idle state, the processor 380 may furtherexecute an instruction of the following operations:

-   -   determining whether the number of idle communication threads in        the thread pool of the application process is not less than a        second preset number if the first target communication thread is        not in an idle state, wherein the second preset number is less        than the first preset number;    -   using any idle communication thread to communicate with the        system process that needs to communicate again if the number of        idle communication threads in the thread pool of the application        process is not less than the second preset number.

In some embodiments, after determining whether the number of idlecommunication threads in the thread pool of the application process isnot less than the second preset number, the processor 380 may furtherexecute an instruction of the following operations:

-   -   creating a second target communication thread if the number of        idle communication threads in the thread pool of the application        process is less than the second preset number;    -   using the second target communication thread to communicate with        the system process that needs to communicate again.

In some embodiments, after determining whether the first targetcommunication thread is in an idle state, the processor 380 may furtherexecute instructions of the following operations:

-   -   creating a second target communication thread if the first        target communication thread is not in an idle state;    -   using the second target communication thread to communicate with        the system process that needs to communicate again.

In some embodiments, after determining whether the application processhas idle communication threads in a thread pool of the applicationprocess, the processor 380 may further execute an instruction of thefollowing operations:

-   -   using the idle communication threads to communicate with the        system process if the application process has idle communication        threads in the thread pool of the application process.

In the above-mentioned embodiments, the description of each embodimenthas its own emphasis. For parts that are not described in detail in acertain embodiment, reference may be made to the relevant descriptionsof other embodiments.

The above embodiments provide a detailed description of the processcommunication method, device, storage medium and mobile terminalprovided by the embodiments of this application, and specific examplesare applied in this document to illustrate the principles andimplementation of this application. The description of the aboveembodiments is only used to help understand the technical solution ofthis application and its core ideas. A person of ordinary skill in theart should understand that it is still possible to modify the technicalsolution recorded in the preceding embodiments, or to replace some ofthe technical features with equivalent ones; and these modifications orreplacements do not make the corresponding technical solution out of thescope of the technical solution of the embodiments of this application.

1. A process communication method, comprising: determining, when asystem process needs to communicate with an application process, whetherthe application process has idle communication threads in a thread poolof the application process; creating a first target communication threadif the application process has no idle communication thread in thethread pool of the application process; and using the first targetcommunication thread to communicate with the system process.
 2. Theprocess communication method according to claim 1, wherein after usingthe first target communication thread to communicate with the systemprocess, the method further comprises: determining again whether theapplication process has idle communication threads in the thread pool ofthe application process when the system process needs to communicatewith the application process again; determining whether the number ofidle communication threads in the thread pool of the application processis not less than a first preset number if the application process has anidle communication thread in the thread pool of the application process;and destroying the first target communication thread after thecommunication between the first target communication thread and thesystem process is completed if the number of idle communication threadsin the thread pool of the application process is not less than the firstpreset number; and using any of the idle communication threads tocommunicate with the system process that needs to communicate again. 3.The process communication method according to claim 2, wherein afterdetermining whether the number of idle communication threads in thethread pool of the application process is not less than a first presetnumber, the method further comprises: determining whether the firsttarget communication thread is in an idle state if the number of idlecommunication threads in the thread pool of the application process isless than a first preset number; and using the first targetcommunication thread to communicate with the system process that needsto communicate again if the first target communication thread is in anidle state.
 4. The process communication method according to claim 3,wherein after determining whether the first target communication threadis in an idle state, the method further comprises: determining whetherthe number of idle communication threads in the thread pool of theapplication process is not less than a second preset number if the firsttarget communication thread is not in an idle state, wherein the secondpreset number is less than the first preset number; and using any idlecommunication thread to communicate with the system process that needsto communicate again if the number of idle communication threads in thethread pool of the application process is not less than the secondpreset number.
 5. The process communication method according to claim 4,wherein after determining whether the number of idle communicationthreads in the thread pool of the application process is not less than asecond preset number, the method further comprises: creating a secondtarget communication thread if the number of idle communication threadsin the thread pool of the application process is less than the secondpreset number; and using the second target communication thread tocommunicate with the system process that needs to communicate again. 6.The process communication method according to claim 3, wherein afterdetermining whether the first target communication thread is in an idlestate, the method further comprises: creating a second targetcommunication thread if the first target communication thread is not inan idle state; and using the second target communication thread tocommunicate with the system process that needs to communicate again. 7.The process communication method according to claim 1, wherein afterdetermining whether the application process has idle communicationthreads in the thread pool of the application process, the methodfurther comprises: using the idle communication threads to communicatewith the system process if the application process has idlecommunication threads in the thread pool of the application process. 8.A computer-readable storage medium, wherein a computer program is storedin the storage medium, and, when being executed by a computer, directsthe computer to execute a method comprising: determining whether anapplication process has idle communication threads in a thread pool ofthe application process when a system process needs to communicate withthe application process; creating a first target communication thread ifthe application process has no idle communication thread in the threadpool of the application process; and using the first targetcommunication thread to communicate with the system process.
 9. Thecomputer-readable storage medium according to claim 8, wherein afterusing the first target communication thread to communicate with thesystem process, the method further comprises: determining again whetherthe application process has idle communication threads in the threadpool of the application process when the system process needs tocommunicate with the application process again; determining whether thenumber of idle communication threads in the thread pool of theapplication process is not less than a first preset number if theapplication process has an idle communication thread in the thread poolof the application process; and destroying the first targetcommunication thread after the communication between the first targetcommunication thread and the system process is completed if the numberof idle communication threads in the thread pool of the applicationprocess is not less than the first preset number; and using any of theidle communication threads to communicate with the system process thatneeds to communicate again.
 10. The computer-readable storage mediumaccording to claim 9, wherein after determining whether the number ofidle communication threads in the thread pool of the application processis not less than a first preset number, the method further comprises:determining whether the first target communication thread is in an idlestate if the number of idle communication threads in the thread pool ofthe application process is less than a first preset number; and usingthe first target communication thread to communicate with the systemprocess that needs to communicate again if the first targetcommunication thread is in an idle state.
 11. The computer-readablestorage medium according to claim 10, wherein after determining whetherthe first target communication thread is in an idle state, the methodfurther comprises: determining whether the number of idle communicationthreads in the thread pool of the application process is not less than asecond preset number if the first target communication thread is not inan idle state, wherein the second preset number is less than the firstpreset number; and using any idle communication thread to communicatewith the system process that needs to communicate again if the number ofidle communication threads in the thread pool of the application processis not less than the second preset number.
 12. The computer-readablestorage medium according to claim 11, wherein after determining whetherthe number of idle communication threads in the thread pool of theapplication process is not less than a second preset number, the methodfurther comprises: creating a second target communication thread if thenumber of idle communication threads in the thread pool of theapplication process is less than the second preset number; and using thesecond target communication thread to communicate with the systemprocess that needs to communicate again.
 13. The computer-readablestorage medium according to claim 10, wherein after determining whetherthe first target communication thread is in an idle state, the methodfurther comprises: creating a second target communication thread if thefirst target communication thread is not in an idle state; and using thesecond target communication thread to communicate with the systemprocess that needs to communicate again.
 14. The computer-readablestorage medium according to claim 8, wherein after determining whetherthe application process has idle communication threads in the threadpool of the application process, the method further comprises: using theidle communication threads to communicate with the system process if theapplication process has idle communication threads in the thread pool ofthe application process.
 15. A mobile terminal, wherein the mobileterminal includes a processor and a memory, a computer program is storedin the memory, and the processor calls the computer program stored inthe memory to execute the method comprising: determining whether anapplication process has idle communication threads in a thread pool ofthe application process when a system process needs to communicate withthe application process; using the idle communication threads tocommunicate with the system process if the application process has idlecommunication threads in the thread pool of the application process;creating a first target communication thread if the application processhas no idle communication thread in the thread pool of the applicationprocess; using the first target communication thread to communicate withthe system process; determining again whether the application processhas idle communication threads in the thread pool of the applicationprocess when the system process needs to communicate with theapplication process again; determining whether the number of idlecommunication threads in the thread pool of the application process isnot less than a first preset number if the application process has anidle communication thread in the thread pool of the application process;and destroying the first target communication thread after thecommunication between the first target communication thread and thesystem process is completed if the number of idle communication threadsin the thread pool of the application process is not less than the firstpreset number; using any of the idle communication threads tocommunicate with the system process that needs to communicate again. 16.The mobile terminal according to claim 15, wherein after determiningwhether the number of idle communication threads in the thread pool ofthe application process is not less than a first preset number, themethod further comprises: determining whether the first targetcommunication thread is in an idle state if the number of idlecommunication threads in the thread pool of the application process isless than a first preset number; and using the first targetcommunication thread to communicate with the system process that needsto communicate again if the first target communication thread is in anidle state.
 17. The mobile terminal according to claim 16, wherein afterdetermining whether the first target communication thread is in an idlestate, the method further comprises: determining whether the number ofidle communication threads in the thread pool of the application processis not less than a second preset number if the first targetcommunication thread is not in an idle state, wherein the second presetnumber is less than the first preset number; and using any idlecommunication thread to communicate with the system process that needsto communicate again if the number of idle communication threads in thethread pool of the application process is not less than the secondpreset number.
 18. The mobile terminal according to claim 17, whereinafter determining whether the number of idle communication threads inthe thread pool of the application process is not less than a secondpreset number, the method further comprises: creating a second targetcommunication thread if the number of idle communication threads in thethread pool of the application process is less than the second presetnumber; and using the second target communication thread to communicatewith the system process that needs to communicate again.
 19. The mobileterminal according to claim 16, wherein after determining whether thefirst target communication thread is in an idle state, the methodfurther comprises: creating a second target communication thread if thefirst target communication thread is not in an idle state; and using thesecond target communication thread to communicate with the systemprocess that needs to communicate again.